#include <iostream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include "../naiev_bayes.h"

using namespace std;

float calc (float val, float mean, float variance2)
{
	float sqrt_2pi = 2.5066283;
	float variance = sqrt ((float)variance2);
	float exp_val = -((val - mean) * (val - mean)) / (2 * variance2);
	if(variance==0)
	{
		cout<<"MMMMMMMMMMMMMMMMMMMM"<<endl;
		exit(1);
	}
	return (1 / (sqrt_2pi * variance)) * exp ((float)exp_val);
}

int main ()
{
	select_attrs sel ("select_attrs.conf");
	vector < attribute_info > *infos = attribute_info::get_all_attr_info ("attr_infos.conf");

	instances*  a = new instances("training.data", sel.bitmap (), infos);
	a->ignore_missing();


	instances* c= new instances("test.data", sel.bitmap (), infos);
	c->data_clean();


	naive_bayes b;
	b.cont_cond_prob=calc;
	b.set_training_set(a);


	b.set_classify_set(c);
	b.learn();

	b.classify();
	b.print_classified_set(cout);

	return 0;
}
